﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using control;
using System.IO;
using System.Xml;

namespace control.Dal
{
    public static class DalCommon
    {
        private static Sach_WebDataContext sachDB = new Sach_WebDataContext();

        public static Sach_WebDataContext SachDB
        {

            get
            {
                if (sachDB == null)
                    sachDB = new Sach_WebDataContext();
                return sachDB;
            }
        }

        internal static string GetWebImagePath()
        {
                string con = "";
                string fileName = "XMLFile1.xml";
                FileStream fs = new FileStream(fileName, FileMode.Open);
                XmlTextReader xtr = new XmlTextReader(fs);
                while (!xtr.EOF)
                {
                    if (xtr.MoveToContent() == XmlNodeType.Element && xtr.Name == "connectweb")
                    {
                        con=xtr.ReadElementString();
                    }
                    else
                    {
                        xtr.Read();
                    }
                }
                fs.Close();
                return con;
        }
        private static string GetServerPath()
        {
            string con = "";
            string fileName = "XMLFile1.xml";
            FileStream fs = new FileStream(fileName, FileMode.Open);
            XmlTextReader xtr = new XmlTextReader(fs);
            while (!xtr.EOF)
            {
                if (xtr.MoveToContent() == XmlNodeType.Element && xtr.Name == "connectserver")
                {
                    con = xtr.ReadElementString();
                }
                else
                {
                    xtr.Read();
                }
            }
            fs.Close();
            return con;
        }
    }
}
